$(function () {
    var orderId = $.query.get("id");
    $.post("/order/findById","id="+orderId,function (orderObj) {
        $("#orderIdSpan").html(orderObj.id);
        $("#nameSpan").html(orderObj.name);
        $("#addressSpan").html(orderObj.address);
        $("#telSpan").html(orderObj.tel);
        $("#createDateSpan").html(orderObj.createDate);
        $("#priceSpan").html(orderObj.price);
        $("#stateSpan").html(orderObj.state);
        var str = "";
        for(var i=0;i<orderObj.infoList.length;i++){
            var obj = orderObj.infoList[i];
            str += `<tr><td>${obj.product.id}</td><td>${obj.product.name}</td>
                    <td>${obj.product.price}</td><td>${obj.num}</td></tr>`;
        }
        $("#productData").html(str);
    })
})

function backToMyOrder() {
    $.post("/user/getUser",null,function (info) {
        var obj = JSON.parse(info);
        if(obj != null){
            location.href="/html/customer/myOrder.html?userId="+obj.id;
        }else {
            location.href="/html/login.html"
        }
    })
}